i finally figured it out with the help of a friend but i have a new problem. when i run the program and play the game i type in 1 for player 2 and 1 for player 1 to see if it works the number it should give is 90 for both but instead it pops up with -36 how do i solve that problem please respond asap
here is the code
at the end part with 2 of }. they have to be there cause it fails to compile if there not unless you can find the error
please help me i want to complete this.
here is the code
Code:
#include <cstdlib> #include <iostream> using namespace std; //health equations int h = 100; int l = 10; int d = 0; int subtraction (int h, int l); int subtraction (int h, int d) { if (h) { return h - l; } else { if (d) { return h - d; } } } int main(int arg, char *argv[]) { int d; int l; int h; int player1; int player2; int choice; //Start Text cout << "hello this is my first game and i want it to be tested \n"; cout << "you are player one \n remember these numbers \n"; cout << "1 = left hand \n"; cout << "2 = right hand \n"; cout << "3 = left foot \n"; cout << "4 = right foot \n"; cout << "5 = blocking \n"; cout << "good luck \n \n \n \n FIGHT!!!! \n \n \n \n"; cout << "player 2 \n"; cin >> player2; cout << "player 1 \n"; cin >> player1; cout << "player 2 \n"; cin >> player2; cout << "player 1 \n"; cin >> player1; cout << "player 2 \n"; cin >> player2; cout << "player 1 \n"; cin >> player1; cout << "player 2 \n"; cin >> player2; cout << "player 1 \n"; cin >> player1; system("PAUSE"); { //damage if ( 1 == 1) { cout << subtraction (h, l) << endl; } else { if ( 1 == 2) { cout << subtraction(h, l) << endl; } else { if ( 1 == 3) { cout << subtraction(h, l) << endl; } else { if ( 1 == 4) { cout << subtraction(h, l) << endl; } else { if ( 1 == 5) { cout << subtraction(h, d) << endl; } } } } } if ( 2 == 1) { cout << subtraction(h, l) << endl; } else { if ( 2 == 2) { cout << subtraction(h, l) << endl; } else { if ( 2 == 3) { cout << subtraction(h, l) << endl; } else { if ( 2 == 4) { cout << subtraction(h, l) << endl; } else { if ( 2 == 5) { cout << subtraction(h, d) << endl; } } } } } if ( 3 == 1) { cout << subtraction(h, l) << endl; } else { if ( 3 == 2) { cout << subtraction(h, l) << endl; } else { if ( 3 == 3) { cout << subtraction(h, d) << endl; } else { if ( 3 == 4) { cout << subtraction(h, d) << endl; } else { if ( 3 == 5) { cout << subtraction(h, l) << endl; } } } } } if ( 4 == 1) { cout << subtraction(h, l) << endl; } else { if ( 4 == 2) { cout << subtraction(h, l) << endl; } else { if ( 4 == 3) { cout << subtraction(h, d) << endl; } else { if ( 4 == 4) { cout << subtraction(h, d) << endl; } else { if ( 4 == 5) { cout << subtraction(h, l) << endl; } } } } } if ( 5 == 1) { cout << subtraction(h, d) << endl; } else { if ( 5 == 2) { cout << subtraction(h, d) << endl; } else { if ( 5 == 3) { cout << subtraction(h, l) << endl; } else { if ( 5 == 4) { cout << subtraction(h, l) << endl; } else { if ( 5 == 5) { cout << subtraction(h, d) << endl; } } } } } system("PAUSE"); return 0; } }
please help me i want to complete this.
Comment